<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户注册</title>
    <link rel="stylesheet" th:href="@{/css/global.css}">
    <link rel="stylesheet" th:href="@{/css/register/style.css}">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
</head>
<body class="light-theme">
<div class="theme-toggle">
    <i class="fas fa-moon"></i>
    <label class="switch">
        <input type="checkbox" id="themeSwitch">
        <span class="slider round"></span>
    </label>
    <i class="fas fa-sun"></i>
</div>

<div class="register-container">
    <div class="register-header">
        <h1>用户注册</h1>
        <p>加入我们，开启全新体验</p>
    </div>

    <form id="registerForm" class="register-form">
        <div class="form-group">
            <label for="username">用户名</label>
            <div class="input-with-icon">
                <i class="fas fa-user"></i>
                <input type="text" id="username" name="username" required placeholder="4-16位字母或数字">
            </div>
            <span class="error-message"></span>
        </div>

        <div class="form-group">
            <label for="password">密码</label>
            <div class="input-with-icon">
                <i class="fas fa-lock"></i>
                <input type="password" id="password" name="password" required placeholder="6-20位密码">
            </div>
            <span class="error-message"></span>
        </div>

        <div class="form-group">
            <label for="confirmPassword">确认密码</label>
            <div class="input-with-icon">
                <i class="fas fa-lock"></i>
                <input type="password" id="confirmPassword" name="confirmPassword" required placeholder="再次输入密码">
            </div>
            <span class="error-message"></span>
        </div>

        <div class="form-group">
            <label for="email">电子邮箱</label>
            <div class="input-with-icon">
                <i class="fas fa-envelope"></i>
                <input type="email" id="email" name="email" required placeholder="有效邮箱地址">
            </div>
            <span class="error-message"></span>
        </div>

        <div class="form-group">
            <label for="emailCode">邮箱验证码</label>
            <div class="code-input-group">
                <div class="input-with-icon">
                    <i class="fas fa-key"></i>
                    <input type="text" id="emailCode" name="emailCode" required placeholder="6位验证码">
                </div>
                <button type="button" id="sendCodeBtn" class="send-code-btn" >获取验证码</button>
            </div>
            <span class="error-message"></span>
        </div>

        <div class="form-group">
            <label for="captcha">图形验证码</label>
            <div class="captcha-container">
                <div class="input-with-icon">
                    <i class="fas fa-shield-alt"></i>
                    <input type="text" id="captcha" name="captcha" required placeholder="输入验证码">
                </div>
                <div class="captcha-img" id="captchaImg" onclick="getCaptcha()"></div>
            </div>
            <span class="error-message"></span>
        </div>

        <div class="form-footer">
            <div class="terms-agreement">
                <input type="checkbox" id="agreeTerms" name="agreeTerms" required checked>
                <label for="agreeTerms">我已阅读并同意<a th:href="@{/page/auth/user-agreement}">用户协议</a>和<a th:href="@{/page/auth/privacy-policy}">隐私政策</a></label>
            </div>

            <button type="button" class="register-btn" id="registerBtn" onclick="register()">
                <span>立即注册</span>
                <i class="fas fa-arrow-right"></i>
            </button>

            <div class="login-link">
                已有账号？<a th:href="@{/page/auth/login}">立即登录</a>
            </div>
        </div>
    </form>
</div>
<div id="customAlert" class="custom-alert">
    <div class="alert-content">
        <div class="alert-icon"></div>
        <div class="alert-message"></div>
        <button class="alert-close">&times;</button>
    </div>
</div>
<script th:src="@{/js/global.js}"></script>
<script th:src="@{/js/reg-style.js}"></script>
<script th:src="@{/js/reg-script.js}"></script>
<script th:src="@{/js/reg-listener.js}"></script>
</body>
</html>
